package com.geper.pattern.composite;

/**
 * @author: lsy
 * @date: 2020-03-09 20:19
 * @description: Test
 */
public class CompositeTest {

public static void main(String[] args) {
    TreeNode root = new TreeNode("tree",1);

    TreeNode tree1 = new TreeNode("treeNode1",2);
    LeafNode leaf1 = new LeafNode("leaf11");
    LeafNode leaf2 = new LeafNode("leaf12");

    tree1.addChild(leaf1);
    tree1.addChild(leaf2);

    TreeNode tree2 = new TreeNode("tree2",2);
    LeafNode leaf3 = new LeafNode("leaf21");
    tree2.addChild(leaf3);

    TreeNode tree3 = new TreeNode("tree3",2);
    LeafNode leaf4 = new LeafNode("leaf31");
    tree3.addChild(leaf4);

    root.addChild(tree1);
    root.addChild(tree2);
    root.addChild(tree3);

    System.out.println(root.show(1));
}

}
